package com.jiang.daily.Q1299;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/02/16 17:51
 */
class Solution {
    public int[] replaceElements(int[] arr) {
        int len = arr.length;

        int max = arr[len - 1];
        for (int i = len - 2; i >= 0; i--) {
            if (max < arr[i]) {
                int t = arr[i];
                arr[i] = max;
                max = t;
            } else {
                arr[i] = max;
            }
        }
        arr[len - 1] = -1;
        return arr;
    }
}
